// worker.js
importScripts('./CSG.js');

onmessage = function(e) {
    const { nowCubeGeometry, toolGeometry } = e.data;

    // 重建 THREE.Mesh 对象
    const nowCube = new THREE.Mesh(nowCubeGeometry);
    const tool = new THREE.Mesh(toolGeometry);

    // 执行 CSG 布尔运算
    const result = CSG.subtract(nowCube, tool);

    // 将结果几何体发送回主线程
    postMessage({
        resultGeometry: result.geometry
    });
};